<?php
include('include/config.inc.php');
/////select techallocation : start/////
$targeteDate = $_REQUEST['targeteYear']."-".$_REQUEST['targeteMonth']."-".$_REQUEST['targeteDay'];
$selectTech = "SELECT timeSlotId,date,technicianId
                 FROM techallocation
                WHERE technicianId = ".$_GET['technicianId']."
                  AND date = '".$targeteDate."' ";
$selectTechQuery = mysql_query($selectTech);
$techArray = array();
$slotArray = array();
$timeSlotIdFound = "";
$techCount = 0;
$slotCount = 0;
while($selectTechArray = mysql_fetch_array($selectTechQuery))
{
	 if($techCount > 0)
	 	  $timeSlotIdFound .= ",";
	 $timeSlotIdFound .= $selectTechArray['timeSlotId'];
   $techCount++;
}
if($techCount == 0)
{
  $selectTechnician = "SELECT timeSlotId,slotName
                         FROM timeslot";
  $selectTechnicianResult = mysql_query($selectTechnician);
  while($technicianRow = mysql_fetch_array($selectTechnicianResult))
  {
    $slotArray['timeSlotId'][$slotCount] = $technicianRow['timeSlotId'];
    $slotArray['slotName'][$slotCount]   = $technicianRow['slotName'];
    $slotCount++;
  }
}
else
{
	///// Select Time Slot : Start
  $selectTechnician = "SELECT timeSlotId,slotName
                         FROM timeslot
                         WHERE timeSlotId NOT IN (".$timeSlotIdFound.")";
  $selectTechnicianResult = mysql_query($selectTechnician);
  while($technicianRow = mysql_fetch_array($selectTechnicianResult))
  {
    $slotArray['timeSlotId'][$slotCount] = $technicianRow['timeSlotId'];
    $slotArray['slotName'][$slotCount]   = $technicianRow['slotName'];
    $slotCount++;
  }
}
  ///// Select Time Slot : End//////
$smarty->assign("slotArray",$slotArray);
$smarty->display("timeSloteAj.tpl");
?>